<template>
  <div class="company-intro">
    <!-- 页面标题 -->
    <div class="page-header">
      <div class="container">
        <h1 class="page-title">{{'公司简介' }}</h1>
        <p class="page-subtitle">{{ pageData.subtitle || '了解FAIR plus机器人全产业链接会的主办方' }}</p>
      </div>
    </div>

    <div class="container">
      <!-- 公司介绍 -->
      <section class="intro-section">
        <h2 class="section-title">{{ pageData.title || '公司介绍' }}</h2>
        <div class="intro-content">
          <div class="intro-text">
            <h3>{{ companyInfo.name || '汉诺威米兰展览（上海）有限公司' }}</h3>
            <div v-html="companyInfo.description || defaultDescription"></div>
          </div>
          <div class="intro-image">
            <img :src="companyInfo.imageUrl || defaultCompanyImage" alt="公司简介" />
          </div>
        </div>
      </section>

      <!-- 核心优势 -->
      <section class="advantages-section">
        <h2 class="section-title">核心优势</h2>
        <div class="advantages-grid">
          <div class="advantage-item" v-for="advantage in advantages" :key="advantage.id">
            <div class="advantage-icon">
              <el-icon><component :is="advantage.icon" /></el-icon>
            </div>
            <h3>{{ advantage.title }}</h3>
            <p>{{ advantage.description }}</p>
          </div>
        </div>
      </section>

      <!-- 发展历程 -->
      <section class="history-section">
        <h2 class="section-title">发展历程</h2>
        <div class="timeline">
          <div class="timeline-item" v-for="(milestone, index) in milestones" :key="milestone.id">
            <div class="timeline-marker">{{ milestone.year }}</div>
            <div class="timeline-content">
              <h3>{{ milestone.title }}</h3>
              <p>{{ milestone.description }}</p>
            </div>
          </div>
        </div>
      </section>

      <!-- 联系方式 -->
      <section class="contact-section">
        <h2 class="section-title">联系方式</h2>
        <div class="contact-content">
          <div class="contact-info">
            <div class="contact-item" v-for="contact in contactInfo" :key="contact.id">
              <div class="contact-icon">
                <el-icon><component :is="contact.icon" /></el-icon>
              </div>
              <div class="contact-details">
                <h4>{{ contact.title }}</h4>
                <p>{{ contact.value }}</p>
              </div>
            </div>
          </div>
          <div class="contact-map">
            <img :src="companyInfo.mapImageUrl || defaultMapImage" alt="公司地址" />
          </div>
        </div>
      </section>
    </div>
  </div>
</template>

<script>
import { ref, onMounted } from 'vue'
import { 
  Star, 
  Connection, 
  Service, 
  User,
  Location,
  Phone,
  Message,
  Clock
} from '@element-plus/icons-vue'
import { subpageApi } from '@/api/user'

export default {
  name: 'CompanyIntro',
  components: {
    Star,
    Connection,
    Service,
    User,
    Location,
    Phone,
    Message,
    Clock
  },
  setup() {
    const pageData = ref({})
    const companyInfo = ref({})
    
    // 默认公司信息
    const defaultCompanyInfo = {
      name: '汉诺威米兰展览（上海）有限公司',
      description: `
        <p>汉诺威米兰展览（上海）有限公司是国际知名的展览会组织者，专注于工业展览领域。我们致力于为展商和观众搭建专业的交流平台，推动工业智能化发展。</p>
        <p>作为汉诺威工博会与中国工博会的承办方，我们拥有丰富的展会组织经验和强大的行业资源，为FAIR plus机器人全产业链接会提供专业的服务保障。</p>
      `,
      imageUrl: 'https://images.pexels.com/photos/3861975/pexels-photo-3861975.jpeg?auto=compress&cs=tinysrgb&w=500&h=400&fit=crop&crop=center',
      mapImageUrl: 'https://images.pexels.com/photos/3861976/pexels-photo-3861976.jpeg?auto=compress&cs=tinysrgb&w=500&h=400&fit=crop&crop=center'
    }
    
    const defaultDescription = `
      <p>汉诺威米兰展览（上海）有限公司是国际知名的展览会组织者，专注于工业展览领域。我们致力于为展商和观众搭建专业的交流平台，推动工业智能化发展。</p>
      <p>作为汉诺威工博会与中国工博会的承办方，我们拥有丰富的展会组织经验和强大的行业资源，为FAIR plus机器人全产业链接会提供专业的服务保障。</p>
    `
    const defaultCompanyImage = 'https://images.pexels.com/photos/3861975/pexels-photo-3861975.jpeg?auto=compress&cs=tinysrgb&w=500&h=400&fit=crop&crop=center'
    const defaultMapImage = 'https://images.pexels.com/photos/3861976/pexels-photo-3861976.jpeg?auto=compress&cs=tinysrgb&w=500&h=400&fit=crop&crop=center'

    // 核心优势数据
    const advantages = ref([
      {
        id: 1,
        title: '专业经验',
        description: '拥有多年工业展览组织经验，深谙行业需求',
        icon: 'Star'
      },
      {
        id: 2,
        title: '全球资源',
        description: '与全球知名展商和观众建立长期合作关系',
        icon: 'Connection'
      },
      {
        id: 3,
        title: '优质服务',
        description: '为展商和观众提供全方位的专业服务',
        icon: 'Service'
      },
      {
        id: 4,
        title: '创新理念',
        description: '持续创新展会模式，引领行业发展',
        icon: 'User'
      }
    ])

    // 发展历程数据
    const milestones = ref([
      {
        id: 1,
        year: '2010',
        title: '公司成立',
        description: '汉诺威米兰展览（上海）有限公司正式成立'
      },
      {
        id: 2,
        year: '2015',
        title: '业务扩展',
        description: '开始承办大型工业展览会，业务范围不断扩大'
      },
      {
        id: 3,
        year: '2020',
        title: '数字化转型',
        description: '推进展会数字化转型，提供线上线下融合服务'
      },
      {
        id: 4,
        year: '2025',
        title: '创新发展',
        description: '承办FAIR plus机器人全产业链接会，开启新的发展篇章'
      }
    ])

    // 联系方式数据
    const contactInfo = ref([
      {
        id: 1,
        title: '公司地址',
        value: '上海市浦东新区世纪大道1500号',
        icon: 'Location'
      },
      {
        id: 2,
        title: '联系电话',
        value: '+86 21 5888 8888',
        icon: 'Phone'
      },
      {
        id: 3,
        title: '电子邮箱',
        value: 'info@fairplus.com',
        icon: 'Message'
      },
      {
        id: 4,
        title: '工作时间',
        value: '周一至周五 9:00-18:00',
        icon: 'Clock'
      }
    ])

    // 加载页面数据
    const loadPageData = async () => {
      try {
        const response = await subpageApi.getSubpageByKey('about', 'company-intro')
        if (response && response.code === '200' && response.data) {
          pageData.value = response.data
          // 如果后端有自定义的公司信息，可以在这里解析
          // 暂时使用默认数据
          companyInfo.value = defaultCompanyInfo
        } else {
          // 使用默认数据
          companyInfo.value = defaultCompanyInfo
        }
      } catch (error) {
        console.error('加载公司简介数据失败:', error)
        // 使用默认数据作为回退
        companyInfo.value = defaultCompanyInfo
      }
    }

    onMounted(() => {
      loadPageData()
    })

    return {
      pageData,
      companyInfo,
      advantages,
      milestones,
      contactInfo,
      defaultDescription,
      defaultCompanyImage,
      defaultMapImage
    }
  }
}
</script>

<style scoped>
.company-intro {
  min-height: 100vh;
  background: linear-gradient(135deg, #320063 0%, #4a0a8a 100%);
}

.page-header {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 120px 0 80px 0;
  margin-top: 0;
  text-align: center;
  color: white;
}

.page-title {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.page-subtitle {
  font-size: 1.2rem;
  opacity: 0.9;
  margin-bottom: 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 内容区域样式 */
.intro-section,
.advantages-section,
.history-section,
.contact-section {
  margin: 80px 0;
  padding: 60px 0;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.section-title {
  font-size: 2.5rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 50px;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* 公司介绍样式 */
.intro-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
}

.intro-text h3 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: #ffd700;
}

.intro-text p {
  font-size: 1.1rem;
  line-height: 1.8;
  margin-bottom: 20px;
  color: rgba(255, 255, 255, 0.9);
}

/* 富文本内图片限制 */
.intro-text :deep(img) {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 10px 0;
  border-radius: 8px;
}

.intro-image img {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* 核心优势样式 */
.advantages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 40px;
}

.advantage-item {
  text-align: center;
  padding: 40px 20px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.advantage-item:hover {
  transform: translateY(-10px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.advantage-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #320063;
}

.advantage-item h3 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 15px;
  color: #ffd700;
}

.advantage-item p {
  font-size: 1rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
}

/* 发展历程样式 */
.timeline {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to bottom, #ffd700, #ffed4e);
  transform: translateX(-50%);
}

.timeline-item {
  position: relative;
  margin-bottom: 60px;
  display: flex;
  align-items: center;
}

.timeline-item:nth-child(odd) {
  flex-direction: row;
}

.timeline-item:nth-child(even) {
  flex-direction: row-reverse;
}

.timeline-marker {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  color: #320063;
  z-index: 2;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.timeline-content {
  flex: 1;
  margin: 0 40px;
  padding: 30px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.timeline-content h3 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 15px;
  color: #ffd700;
}

.timeline-content p {
  font-size: 1rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
}

/* 联系方式样式 */
.contact-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: start;
}

.contact-info {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.contact-item {
  display: flex;
  align-items: center;
  padding: 25px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.3s ease;
}

.contact-item:hover {
  transform: translateX(10px);
}

.contact-icon {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #320063;
  margin-right: 20px;
  flex-shrink: 0;
}

.contact-details h4 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #ffd700;
}

.contact-details p {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.5;
}

.contact-map img {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-title {
    font-size: 2rem;
  }
  
  .page-subtitle {
    font-size: 1rem;
  }

  .section-title {
    font-size: 2rem;
  }

  .intro-content,
  .contact-content {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .advantages-grid {
    grid-template-columns: 1fr;
  }

  .timeline::before {
    left: 30px;
  }

  .timeline-item {
    flex-direction: row !important;
  }

  .timeline-marker {
    width: 50px;
    height: 50px;
    font-size: 1rem;
  }

  .timeline-content {
    margin-left: 20px;
    margin-right: 0;
  }

  .contact-item {
    padding: 20px;
  }

  .contact-icon {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
    margin-right: 15px;
  }
}
</style> 